home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / PROCESS.N < prev    next >
Text File  |  1995-11-08  |  2KB  |  58 lines

  1. Define TestProcess() 
  2. /*
  3.     demonstrate the ability to compile and run code on the fly (as they say)
  4.     with the Process intrinsic function.
  5.  
  6.     Sample input to Expression could be :-
  7.         DateToday() - "4/10/1993"
  8.     This would return the number of days since this comment was first 
  9.     entered.
  10.  
  11.     Sample input to Process string, or Expression could be :-
  12.         TestMultiEd()
  13.     This will run the multi line edit demonstration.
  14.  
  15.     Note that as an expression, 
  16.         TestMultiEd 
  17.     and 
  18.         TestMultiEd()
  19.     are different.  The first returns the value of a local variable, which
  20.     is the null string, the second will perform the TestMultiEd function, 
  21.     passing no arguments.
  22. */
  23. {
  24.     scr = SdCreate(, -1, -1, 13, 72, "Process String Demo");
  25.     rad = "e";              /* variable holds value of radio button */
  26.     SdPrompt(scr, 0,  1, "Enter Expression:");
  27.     SdMultiLine(scr, "exp", 1, 1, 1, 70, 4, &expr, 250, "Caret");
  28.     SdPrompt(scr, 5,  1, "Result :");
  29.     SdMultiLine(scr, "res", 0, 6, 1, 70, 4,, 250);
  30.  
  31.     SdRadio(scr, "r0", 1, 10, 48, 20, &rad, "Expression", "e", 131);
  32.     SdRadio(scr, "r1", 1, 11, 48, 20, &rad, "Process", "p", 132);
  33.  
  34.     SdButton(scr, "ok",   1, 11,  8, 10, "OK", "", 1);
  35.     SdButton(scr, "can",  1, 11, 24, 10, "Cancel", "", 2);
  36.  
  37.     while ((cmd = SdEdit(scr)) != 2 && cmd != 3) {
  38.         SdUpdate(scr);
  39.         switch (cmd) {
  40.         case 1:
  41.             procstr = (rad == "e") ? "Eval(" . expr : expr;
  42.             if (errTxt = Process(procstr, &outstr))
  43.                 MsgWait("TestProcess", errTxt);
  44.             SdFieldSet(scr, "res", outstr);
  45.             break;
  46.  
  47.         case 131:
  48.             SdPrompt(scr, 0,  1, "Enter Expression:");
  49.             break;
  50.  
  51.         case 132:
  52.             SdPrompt(scr, 0,  1, "Enter String to Process:");
  53.             break;
  54.         }
  55.     }
  56.     SdDestroy(scr);
  57. }
  58.